package vn.smartoffice.promail.entity;

import java.beans.Transient;
import java.io.IOException;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.SneakyThrows;

import org.zkoss.image.AImage;
import org.zkoss.image.Image;

import vn.smartoffice.entity.AbstractModel;
import vn.smartoffice.entity.User;

@Data
@EqualsAndHashCode(exclude = {"maiContactGroup", "user"} ,callSuper = true)
public class MailContact extends AbstractModel {
	private static final long serialVersionUID = -5470729201572076147L;
	private User user;
	private MailContactGroup maiContactGroup;
	private String firstName;
	private String lastName;
	private String email;
	private String address;
	private String website;
	private String facebook;
	private String yahoo;
	private String skype;
	private byte[] avatar;

	@SneakyThrows(IOException.class)
	@Transient
	public Image getAvatarImage() {
		if (avatar != null) {
			return new AImage("avata.jpg", avatar);
		} else {
			return null;
		}
	}
}
